import java.io.IOException;

import javax.microedition.media.Manager;
import javax.microedition.media.MediaException;
import javax.microedition.media.Player;

public class MediaPlayer {
	
	private Player menu;
	private Player put;
	private Player score;

	public MediaPlayer() {
		try {
			menu = Manager.createPlayer(getClass().getResourceAsStream(
					"/menu.mid"), "audio/midi");
			put = Manager.createPlayer(getClass().getResourceAsStream(
					"/put.mid"), "audio/midi");
			score = Manager.createPlayer(getClass().getResourceAsStream(
					"/score.mid"), "audio/midi");
			menu.prefetch();
			menu.setLoopCount(-1);
			put.prefetch();
			score.prefetch();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (MediaException e) {
			e.printStackTrace();
		}
	}

	public void loopMenu() {
		try {
			menu.setMediaTime(0);
			menu.start();
		} catch (MediaException e) {
			e.printStackTrace();
		}
	}

	public void stopMenu() {
		try {
			menu.stop();
		} catch (MediaException e) {
			e.printStackTrace();
		}
	}

	public void playPut() {
		try {
			put.setMediaTime(0);
			put.start();
		} catch (MediaException e) {
			e.printStackTrace();
		}
	}

	public void playScore() {
		try {
			score.setMediaTime(0);
			score.start();
		} catch (MediaException e) {
			e.printStackTrace();
		}
	}
}
